Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@highlight-ui/typography

Package Overview
Dependencies
Maintainers
9
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@highlight-ui/typography

This is the Typography package used by UI-components in Personio

  • 5.5.1
  • npm
  • Socket score

Version published
Weekly downloads
4.3K
increased by92.84%
Maintainers
9
Weekly downloads
 
Created
Source

npm personio.design storybook.personio.design

@highlight-ui/typography

Typography component which manages the usage of typographic design tokens through props.

Features

  • Polymorphic component
  • Supports changing typographic styles through props that accept design tokens
  • Supports customization through CSS classes
  • Supports components that Pre-combines fontFamily, fontSize, fontWeight, letterSpacing, lineHeight, textTransform, and textDecoration
    • Heading: offers variants in choice of 2xlarge, xlarge, large, medium, small and xsmall which are identical with the Figma assets.
    • Body: Body component offers variants in choice of large, base, small, strong-large, strong-base and strong-small which are identical with the Figma assets.

Installation

Using npm:

npm install @highlight-ui/typography

Using yarn:

yarn add @highlight-ui/typography

Using pnpm:

pnpm add @highlight-ui/typography

In your (S)CSS file:

@import url('@highlight-ui/typography');

Once the package is installed, you can import the library:

import { Typography } from '@highlight-ui/typography';

Getting started

import React from 'react';
import { Typography } from '@highlight-ui/typography';

export default function Example() {
  return <Typography>Text</Typography>;
}

Heading component

import React from 'react';
import { Heading } from '@highlight-ui/typography';

export default function Example() {
  return <Heading variant="xlarge">some large heading</Heading>;
}

Body component

import React from 'react';
import { Body } from '@highlight-ui/typography';

export default function Example() {
  return <Body variant="large">some large text</Body>;
}

Advanced usage

Change typographic style through design tokens

By default, the Typography component applies the body-base typography token. To override this default style, the token prop can be used to change the applied typographic style.

import React from 'react';
import { Typography } from '@highlight-ui/typography';

export default function Example() {
  return <Typography token="heading-medium">Text</Typography>;
}

Changing the rendered HTML tag

By default, the Typography component renders a p element. To change the HTML tag that will be used for rendering, the component prop can be used to specify any other HTML tag.

Note: the component prop is of type string, please use valid HTML tags when using this prop. For example: h1, h2, h3, h4, h5, h6, p, or span.

import React from 'react';
import { Typography } from '@highlight-ui/typography';

export default function Example() {
  return <Typography component="h1">Text</Typography>;
}

Overriding font properties

Individual font properties can be overriden through props such as fontFamily. Other properties that can be overriden are: fontSize, fontWeight, letterSpacing, lineHeight, textTransform, and textDecoration. For more details on these props, check out the component's props table.

import React from 'react';
import { Typography } from '@highlight-ui/typography';

export default function Example() {
  return <Typography fontFamily="mono">Text</Typography>;
}

Customizing through a CSS class name

Use the className prop to customize the component through CSS classes.

import React from 'react';
import { Typography } from '@highlight-ui/typography';
import styles from './customStyles.scss';

export default function Example() {
  return <Typography className={styles.wrappedText}>Text</Typography>;
}

Props 📜

Typography

PropTypeRequiredDefaultDescription
classNamestringnoundefinedAllows providing a custom class name
componentstringno'p'Specifies an HTML tag for rendering the element
tokenTypographyTokenno'body-base'Specifies typography token
colorTypographyColorTokennoundefinedSpecifies a text color
fontFamilyTypographyFontFamilyTokennoundefinedSpecifies font family
fontSizeTypographyFontSizeTokennoundefinedSpecifies font size
fontWeightTypographyFontWeightTokennoundefinedSpecifies font weight
letterSpacingTypographyLetterSpacingTokennoundefinedSpecifies letter spacing
lineHeightTypographyLineHeightTokennoundefinedSpecifies line height
textTransformTypographyTextCaseTokennoundefinedSpecifies text case
textDecorationTypographyTextDecorationTokennoundefinedSpecifies text decoration

Also accepts props from the React.HTMLAttributes<HTMLElement> type.

Heading

PropTypeRequiredDefaultDescription
colorTypographyColorTokennotext-defaultSpecifies a text color
ash1,h2, h3, h4, h5, h6noh1Specifies an HTML tag for rendering the element
variant2xlarge, xlarge, large, medium, small, xsmallnosmallSpecifies a variant for rendering the element

Body

PropTypeRequiredDefaultDescription
colorTypographyColorTokennotext-defaultSpecifies a text color
asp,spannospanSpecifies an HTML tag for rendering the element
variantlarge, base, small, strong-large, strong-base, strong-smallnobaseSpecifies a variant for rendering the element

Custom types 🔠

TypeValuesDescription
TypographyTokenTypography token namesUsed for the token prop
TypographyColorToken"Text" and "Text On" color token namesUsed for the color prop
TypographyFontFamilyToken'default' | 'mono'Used for the fontFamily prop
TypographyFontSizeToken'small' | 'base' | 'large' | 'xsmall' | 'xlarge' | '2xl' | '3xl'Used for the fontSize prop
TypographyFontWeightToken'bold' | 'regular' | 'semi-bold'Used for the fontWeight prop
TypographyLetterSpacingToken'base'Used for the letterSpacing prop
TypographyLineHeightToken'base' | 'large' | 'xlarge'Used for the lineHeight prop
TypographyTextCaseToken'none' | 'uppercase'Used for the textTransform prop
TypographyTextDecorationToken'none' | 'underline'Used for the textDecoration prop

Testing

import React from 'react';
import { render } from '@testing-library/react';
import { Typography } from '@highlight-ui/typography';

describe('TestExample', () => {
  it('test description', () => {
    render(<Typography>Text</Typography>);
    // write your expect here
  });
});

Place in design system 💻

The Typography component is being used in all of Highlight UI to display any kind of text element.

Contributing 🖌️

If you're interested in contributing, please visit our contribution page.

FAQs

Package last updated on 19 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc